.section .data
.section .bss
.lcomm BUFFER_DATA,500

.section .text

.globl _start

_start:

	movl %esp, %ebp
	subl $8,%esp
open_files:
open_fd_in:

	movl $5,%eax
	movl 8(%ebp),%ebx
	movl $0,%ecx
	movl $0666,%edx
	int $0x80

store_fd_in:
	movl %eax,-4(%ebp)
open_fd_out:
	movl $5,%eax
	movl 12(%ebp),%ebx
	movl $03101,%ecx
	movl $0666,%edx
	int $0x80

store_fd_out:
	movl %eax,-8(%ebp)

read_loop_begin:
	movl $3,%eax
	movl -4(%ebp),%ebx
	movl $BUFFER_DATA,%ecx
	movl $500,%edx
	int $0x80

	cmpl $0 , %eax
	jle end_loop
continue_read_loop:
	pushl $BUFFER_DATA
	pushl %eax
	
	movl %eax,%edx
	movl $4,%eax
	movl -8(%ebp),%ebx
	movl $BUFFER_DATA,%ecx
	int $0x80
	
	jmp read_loop_begin
end_loop:
	movl $6,%eax
	movl -8(%ebp),%ebx
	int $0x80
	
	movl $6,%eax
	movl -4(%ebp),%ebx
	int $0x80
	
	movl $1,%eax
	movl $0,%ebx
	int $0x80


